using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using LitTools;
public partial class Enemy : IObjectPoolItem
{
    private LevelController controller;
    private GameObject enemyGo;
    private float moveSpeed = 1;

    void IObjectPoolItem.OnRent(params object[] args)
    {
        enemyGo.transform.position = controller.GetEnemyPositionRandom();
        enemyGo.SetActive(true);
    }

    void IObjectPoolItem.OnRecycle()
    {
        enemyGo.SetActive(false);
    }

    void IObjectPoolItem.OnCreate(params object[] args)
    {
        controller = args[0] as LevelController;
        enemyGo = controller.CreateEnemy();
        enemyGo.transform.position = controller.GetEnemyPositionRandom();
    }

    void IObjectPoolItem.OnRelease()
    {
        GameObject.Destroy(enemyGo);
    }
}

public partial class Enemy
{
    public void Update()
    {
        enemyGo.transform.Translate(moveSpeed * Time.deltaTime * Vector2.down);
    }

    public bool IsDeath()
    {
        return enemyGo.transform.position.y < -10;
    }
}